


package netudp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;


public class UTLDemo {

	public static void main(String[] args) throws IOException {
		try {
			URL url=new URL("http://news.qq.com/a/20170320/006038.htm "

);
			System.out.println(url.getProtocol());
			System.out.println(url.getHost());
			//System.out.println(url.getPort());
			System.out.println(url.getPath());
			URLConnection uc=url.openConnection();
			InputStream in= uc.getInputStream();
			InputStreamReader isr=new InputStreamReader(in,"gb2312");
			BufferedReader br=new BufferedReader(isr);
			String s=br.readLine();
			while(s!=null){
				System.out.println(s);
				s=br.readLine();
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}



